#pragma once
#include "imtPublic.h"
#include "wx/wx.h"
namespace iMate
{
	using namespace Ogre;

	class WorldEditorApp : public wxControl, public Ogre::Singleton<WorldEditorApp>

	{
		DECLARE_CLASS(WorldEditorApp)
	public:

		WorldEditorApp (wxFrame* parent);

		~WorldEditorApp();

		/** Renders a single Ogre frame */
		void update();

		/** Returns the currently used camera */
		inline Ogre::Camera* getCamera() const {return mCamera;}
		/** Sets a new camera for rendering */
		inline void setCamera(Ogre::Camera* camera){mCamera = camera;}

		inline Ogre::SceneManager* getSceneManager() const {return mSceneMgr;}

		void add();

		WorldEditorApp& getSingleton();

		WorldEditorApp* getSingletonPtr();

	protected:
		DECLARE_EVENT_TABLE()

	private:

		/** Creates an ogre rendering window and all other default objects
		such as the Ogre Root, default camera, default scene manager etc */ 
		void createOgreRenderWindow();
		/** Toggles the rendering timer on/off */
		void toggleTimerRendering();

		/** Callback function to a window resize event */
		void OnSize(wxSizeEvent& event);
		/** Callback function to a window paint event */
		void OnPaint(wxPaintEvent& event);
		/** Callback function to an EraseBackground event */
		void OnEraseBackground( wxEraseEvent& );
		/** Callback function to a timer "tick" event */
		void OnRenderTimer(wxTimerEvent& event);

		/* WX members */
		/** Rendering timer */
		wxTimer	mTimer;

		/* Ogre members */
		/** Local Ogre::Root pointer */
		Ogre::Root* mRoot;
		/** Local Ogre::Viewport pointer */
		Ogre::Viewport* mViewPort;
		/** Local Ogre::Camera pointer */
		Ogre::Camera* mCamera;
		/** Local Ogre::SceneManager pointer */
		Ogre::SceneManager* mSceneMgr;
		/** Local Ogre::RenderWindow pointer */
		Ogre::RenderWindow* mRenderWindow;

		/* Set to false until WorldEditorApp is completely initialized */
		bool mIsInitialized;


	};

}